package top.wuyang.springboot3.entity.contact;

import com.baomidou.mybatisplus.annotation.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import top.wuyang.springboot3.entity.auth.TbUser;
import top.wuyang.springboot3.validate.CommonValidate;

import java.io.Serial;
import java.io.Serializable;

@Data
// 通讯录
@TableName("tb_contact")
public class TbContact implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    // 主键标识，自增主键
    @TableId(type = IdType.AUTO)
    private Integer id;

    // 用户id不能修改
    @TableField(updateStrategy = FieldStrategy.NEVER)
    private Integer uid;

    @NotBlank(message = "用户名不能为空", groups = {CommonValidate.Add.class, CommonValidate.Edit.class})
    @Length(max = 20, message = "用户名长度不能超过20")
    private String username;

    @Pattern(message = "手机号格式不正确", regexp = CommonValidate.PHONE, groups = {CommonValidate.class})
    @NotBlank(message = "手机号不能为空", groups = {CommonValidate.Add.class, CommonValidate.Edit.class})
    @Length(max = 20, message = "手机号长度不能超过11")
    private String phone;

    @Pattern(message = "邮箱格式不正确", regexp = CommonValidate.EMAIL, groups = {CommonValidate.class})
    @NotBlank(message = "邮箱不能为空", groups = {CommonValidate.Add.class, CommonValidate.Edit.class})
    @Length(max = 255, message = "邮箱长度不能超过255")
    private String email;

    @NotBlank(message = "地址不能为空", groups = {CommonValidate.Add.class, CommonValidate.Edit.class})
    @Length(max = 255, message = "地址长度不能超过255")
    private String address;

}
